export const request = (options) => {
	return new Promise((resolve, reject) => {
		// ① 读取本地保存的 JWT（登录成功后需 setStorageSync）
		const token = uni.getStorageSync('token')
		// ② 合并调用方 header 与 Authorization
		const mergedHeader = {
			...(options.header || {}),
			...(token ? { Authorization: `Bearer ${token}` } : {})
		}
		uni.request({
			...options,
			header: mergedHeader,
			success: (res) => {
				if (res.statusCode === 200 && res.data.code === 200) {
					resolve(res.data);
				} else {
					reject(res.data);
				}
			},
			fail: (err) => {
				reject(err);
			}
		});
	});
};